<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/validateEngine/jquery.validationEngine.min.js',2); ?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/validateEngine/jquery.validationEngine-zh_CN.js',2); ?>
<?php Yii::app()->clientScript->registerCssFile(Yii::app()->params['static'].'assets/css/validationEngine.jquery.css'); ?>
<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->params['static'].'assets/js/bootbox.min.js',2); ?>
<div class="page-header">
							<h1>
								<?php echo $sur->name; ?> 问卷
								<small>
									<i class="icon-double-angle-right"></i>
									共有 <?php echo $sur->questionnum ; ?> 道题目
								</small>
							</h1>
</div>
<div class="row">
	<div class="col-xs-12">
		<div class="row">
			<form class="form-horizontal" role="form" id="post-form" method="post" action="<?php echo Yii::app()->createUrl('stusurvey/addsurvey')?>">
                <?php echo '<input type="hidden" name="surveyId" value="'.$sur->surveyId.'">'; ?>
				<?php  
									$i = 1;
									foreach($qus  as $q){
										if($q->type == 'duoxuan'){
											$content = json_decode($q->content);
										echo '<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-field-1">('.$i++.')</label>

											<div class="col-sm-4">
											 <div class="widget-box">
														<div class="widget-header widget-header-flat">
															<label class="control-label bolder blue">'.$q->name.'</label>
														</div>

														<div class="widget-body">
															<div class="widget-main">
															<div class="control-group">';
																	foreach($content as $key => $value){
																		echo 
																		'<div class="checkbox">
																			<label>
																				<input type="checkbox" class="ace validate[required]" name="answer['.$q->questionId.'][]" value="'.$key.'" >
																				<span class="lbl">&nbsp;&nbsp;&nbsp;'.$value.'</span>
																			</label>
																	    </div>';
																	}

																echo '</div>
															</div>
														</div>
												</div>
												
											</div>
										</div>';
										
									}else if($q->type == 'danxuan'){
								         $content = json_decode($q->content);
									echo '
									<div class="space-4"></div>
                                    <div class="form-group">
										<label class="col-sm-4 control-label no-padding-right" for="form-field-1">('.$i++.')</label>
                                        <div class="col-sm-4">
										 <div class="widget-box">
													<div class="widget-header widget-header-flat">
														<label class="control-label bolder blue">'.$q->name.'</label>
													</div>

													<div class="widget-body">
														<div class="widget-main">
														  <div class="control-group">';
																foreach($content as $key => $value){
																echo '<div class="radio">
																	<label>
																		<input  type="radio" class="ace validate[required]" name="answer['.$q->questionId.'][]" value="'.$key.'">
																		<span class="lbl">&nbsp;&nbsp;&nbsp;'.$value.'</span>
																	</label>
																</div>';
																}
														echo '
														</div>
														</div>
													</div>
											</div>
										
									</div>
									</div>
									<div class="space-4"></div>';
									
									}else if($q->type == 'tiankong'){
										echo '
										<div class="form-group">
											<label class="col-sm-4 control-label no-padding-right" for="form-input-readonly">('.$i++.')</label>

											<div class="col-sm-4">
												<div class="widget-box">
														<div class="widget-header widget-header-flat">
															<label class="control-label bolder blue">'.$q->name.'</label>
														</div>

														<div class="widget-body">
															<div class="widget-main">
															 <textarea name="answer['.$q->questionId.'][]" col="10" rows="6" class="form-control validate[required]" id="form-field-8" placeholder="请根据题目内容填写相关信息，谢谢合作"></textarea>
															</div>
														</div>
												</div>
												
											</div>
										</div>';
									}
								}
					?>
									<div class="space-4"></div>
									<div class="clearfix form-actions">
										<div class="col-md-offset-5 col-md-7">
											<button class="btn btn-info" type="button" id="post">
												<i class="icon-ok bigger-110"></i>
												提交
											</button>

											
										</div>
									</div>

								
				</form>
			</div>
	</div>
</div>
	<script type="text/javascript">
         jQuery(function($){
			 
			 $('#post').on('click',function(){
				 
				bootbox.confirm('谢谢答题，若问卷中有提示，请按照提示修正问题，谢谢合作',function(result){
					 if(result){
						 $('#post-form').submit();
						 
					 }
					
				}); 
				 
			 });
			 
			 
	     //begin the validate
		  $(".form-horizontal").validationEngine("attach",{ 
				promptPosition:"topRightt", 
				scroll:true,
				validateNonVisibleFields:false,
		  }); 
			 
		 })
	</script>
